// pages/openbillbox/sendaddress/sendaddress.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    name: "",
    phone: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    if (options.faAddressInfo) {
      let faAddressInfo = JSON.parse(options.faAddressInfo);
      this.setData({
        name: faAddressInfo.name,
        phone: faAddressInfo.phone
      })
    }
  },
  //获取发件人姓名
  getName: function(e) {
    this.setData({
      name: e.detail.value
    })
  },
  //获取发件人电话
  getPhone: function(e) {
    this.setData({
      phone: e.detail.value
    })
  },
  //发件人地址提交
  faAddressSub: function() {
    let {
      name,
      phone, 
    } = this.data;

    let faAddressInfo = {
      name: name,
      phone: phone, 
    }
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2]; //上一个页面 
    //直接调用上一个页面的setData()方法，把数据存到上一个页面中去  
debugger;
    prevPage.setData({
      faAddressInfo: faAddressInfo
    })
    wx.navigateBack(); 
  }
})